<template>
	<view>
		<u-navbar title="商品详情" leftText="返回" :autoBack="true" placeholder />
		<image :src="detail.banners[0]"></image>
		<view class="detail">
			<view class="name">
				{{detail.masterName}}
			</view>
			<view class="desc">
				{{detail.slaveName}}
			</view>
			<view class="price">
				<text>￥{{(detail.minPrice/100).toFixed(2)}}</text>
				<text>￥{{(detail.maxPrice/100).toFixed(2)}}</text>
			</view>
		</view>

		<view class="footer">
			<view class="left">
				<view class="item">
					<u-icon size="35px" name="chat"></u-icon>
					<text>客服</text>
				</view>
				<view class="item">
					<u-icon size="35px" name="heart"></u-icon>
					<text>收藏</text>
				</view>
				<view class="item">
					<u-icon size="40px" name="shopping-cart"></u-icon>
					<text>购物车</text>
				</view>
			</view>
			<view class="right">
				<u-button text="加入购物车"
					color="linear-gradient(to right, #ffd01e,#ff8917)"></u-button>
				<u-button text="立即购买" color="linear-gradient(to right, #ff6034,#ee0a24)"></u-button>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 详情的数据
				detail: {}
			}
		},
		onLoad(options) { 
			this.getDetail(options.productId);
		},
		
		
		methods: {
			// 获取详情
			getDetail(productId) {
				var data = {
					productId: productId,
				}
				this.$get('/product/detail',data).then((res)=>{
					console.log(res);
					this.detail = res.result;
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #f4f4f4;
	}

	image {
		width: 100%;
		background-color: #fff;
		display: flex;
		background-color: #e8e8e8;
	}

	.detail {
		background-color: #fff;
		padding: 10px;
	}

	.name {
		font-size: 18px;
	}

	.price {
		margin-top: 5px;
	}

	.price text:nth-child(1) {
		font-size: 18px;
		color: #c03131;
	}

	.price text:nth-child(2) {
		margin-left: 10px;
		color: #999;
		text-decoration: line-through;
	}

	.footer {
		padding: 5px;
		/* border: 1px solid red; */
		position: fixed;
		bottom: 0;
		width: 100%;
		/* height: 50px; */
		box-sizing: border-box;
		background-color: #fff;
		display: flex;
		align-items: center;
		padding-left: 15px;
		justify-content: space-between;
	}

	.footer .left {
		display: flex;
	}

	.footer .item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin-left: 10px;
	}

	.footer .item text {
		margin-top: -5px;
	}

	.footer .right {
		display: flex;
	}

	.footer uni-button {
		margin: 0;
		border-radius: 0;
	}
	.footer uni-button:first-child {
		border-top-left-radius: 100px;
	}
</style>